import Vue from "vue";
import Router from "vue-router";
import Layout from "../layout/index";

Vue.use(Router);

export const constantRouterMap = [
  {
    path: "/login",
    meta: { title: "登录", noCache: true },
    component: resolve => require(["@/views/login"], resolve),
    hidden: true
  },
  {
    path: "/404",
    component: resolve => require(["@/views/features/404"], resolve),
    hidden: true
  },
  {
    path: "/401",
    component: resolve => require(["@/views/features/401"], resolve),
    hidden: true
  },
  {
    path: "/redirect",
    component: Layout,
    hidden: true,
    children: [
      {
        path: "/redirect/:path*",
        component: resolve => require(["@/views/features/redirect"], resolve)
      }
    ]
  },
  {
    path: "/",
    component: Layout,
    redirect: "/dashboard",
    children: [
      {
        path: "dashboard",
        component: resolve => require(["@/views/home"], resolve),
        name: "Dashboard",
        meta: {
          title: "首页",
          icon: "index",
          affix: true,
          noCache: true
        }
      }
    ]
  },
  {
    path: "/kj",
    component: Layout,
    hidden: false,
    meta: { title: "我的" },
    redirect: "noredirect",
    children: [
      {
        path: "dem",
        component: resolve => require(["@/views/my/dem/demHome.vue"], resolve),
        name: "dem",
        meta: {
          title: "dem测试",
          icon: "menu",
          noCache: true
        }
      },
      {
        path: "/kj/sysbasic",
        component: resolve => require(["@/views/my/index.vue"], resolve),
        name: "sysbasic",
        meta: {
          title: "基本信息",
          icon: "menu",
          noCache: true
        }
      },

      {
        path: "/kj/sysuser",
        component: resolve =>
          require(["@/views/my/sysuser/sysuserHome.vue"], resolve),
        name: "sysuserHome",
        meta: {
          title: "用户信息",
          icon: "menu",
          noCache: false
        }
      },
      {
        path: "/kj/sysrole",
        component: resolve =>
          require(["@/views/my/sysrole/index.vue"], resolve),
        name: "sysrole",
        meta: {
          title: "角色信息",
          icon: "menu",
          noCache: false
        }
      },
      {
        path: "/kj/sysjob",
        component: resolve =>
          require(["@/views/my/sysjob/sysjobHome.vue"], resolve),
        name: "sysjobHome",
        meta: {
          title: "岗位信息",
          icon: "menu",
          noCache: false
        }
      },
      {
        path: "/kj/sysdict",
        component: resolve =>
          require(["@/views/my/sysdict/index.vue"], resolve),
        name: "index",
        meta: {
          title: "字典管理",
          icon: "menu",
          noCache: true
        }
      },
      {
        path: "/kj/sysmenu",
        component: resolve =>
          require(["@/views/my/sysmenu/sysmenuHome.vue"], resolve),
        name: "sysmenuHome",
        meta: {
          title: "菜单管理",
          icon: "menu",
          noCache: true
        }
      }
    ]
  },
  {
    path: "/user",
    component: Layout,
    hidden: true,
    redirect: "noredirect",
    children: [
      {
        path: "center",
        component: resolve => require(["@/views/system/user/center"], resolve),
        name: "个人中心",
        meta: { title: "个人中心" }
      }
    ]
  }
];

export default new Router({
  // mode: 'hash',
  mode: "history",
  scrollBehavior: () => ({ y: 0 }),
  routes: constantRouterMap
});
